// 手写new关键词
function myNew(fn, ...args) {
  const obj = Object.create(fn.prototype);
  const result = fn.apply(obj, args);
  return result instanceof Object ? result : obj;
}

let obj = {
  name: "name",
  age: 13,
}

Object.defineProperty(obj, "address", {
  configurable: true,
  enumerable: true,
  writable: true,
  value: "address"
})
Object.defineProperty(obj, "id", {
  get: function () {
    return 1;
  },
  set: function (value) {
    console.log(value);
  },
  configurable: true,
  enumerable: true,
})
console.log(obj.address);
console.log(obj.id);

let obj2 = {
  name: "name"
}
Object.defineProperty(obj2, "address", {
  get: function () {
    return this._address;
  },
  set: function (value) {
    this._address = value;
  },
  configurable: true,
  enumerable: true,
})

obj2.address = "dddd"

console.log(obj2.name);
console.log(obj2.address);